var ipconfig = "http://192.168.3.133:8080"//服务器ip地址
Page({
  data: {


    radioItems: [
      { name: 'cell standard', value: '0' },
      { name: 'cell standard', value: '1', checked: true }
    ],
    checkboxItems: [
      { name: 'standard is dealt for u.', value: '0', checked: true },
      { name: 'standard is dealicient for u.', value: '1' }
    ],
  
    date: "2016-09-01",
    time: "12:01",
    admin_nameIndex:0,
    phone:'',

    isAgree: false
  },
  showTopTips: function () {
    var a=this.data.phone
    wx.makePhoneCall({
      phoneNumber:a+""
    })
 
  },
   onLoad: function () {
     var that=this;
    wx.request({
      url: ipconfig+'/WxSteward',
      method: "post",
      header: {
        'content-type': 'application/x-www-form-urlencoded',
        'Cookie': wx.getStorageSync("session")
      },
      
      success: function (res) {
        var admin_phone=[];
        var admin_name=[];
        for(var i=0;i<res.data.length;i++){
          admin_phone.push(res.data[i].admin_phone);
          admin_name.push(res.data[i].admin_name);
        }
        if(admin_phone.length>0){
        that.setData({
          admin_phone: admin_phone,
          admin_name:admin_name,
      
          phone: admin_phone[0],
  
        })
        }


      }
    })
  },

  radioChange: function (e) {
    console.log('radio发生change事件，携带value值为：', e.detail.value);

    var radioItems = this.data.radioItems;
    for (var i = 0, len = radioItems.length; i < len; ++i) {
      radioItems[i].checked = radioItems[i].value == e.detail.value;
    }

    this.setData({
      radioItems: radioItems
    });
  },
  checkboxChange: function (e) {
    console.log('checkbox发生change事件，携带value值为：', e.detail.value);

    var checkboxItems = this.data.checkboxItems, values = e.detail.value;
    for (var i = 0, lenI = checkboxItems.length; i < lenI; ++i) {
      checkboxItems[i].checked = false;

      for (var j = 0, lenJ = values.length; j < lenJ; ++j) {
        if (checkboxItems[i].value == values[j]) {
          checkboxItems[i].checked = true;
          break;
        }
      }
    }

    this.setData({
      checkboxItems: checkboxItems
    });
  },
  bindDateChange: function (e) {
    this.setData({
      date: e.detail.value
    })
  },
  bindTimeChange: function (e) {
    this.setData({
      time: e.detail.value
    })
  },

  bindCountryChange: function (e) {
    console.log('管家 发生选择改变，携带值为', e.detail.value);
    var phone =this.data.admin_phone[e.detail.value]
    this.setData({
      admin_nameIndex: e.detail.value,
      phone: phone
    })
  },

  bindAgreeChange: function (e) {
    this.setData({
      isAgree: !!e.detail.value.length
    });
  }

});